package com.allwees.bs.module.mms.service.impl;

import com.allwees.bs.module.mms.dao.RetailerDao;
import com.allwees.bs.module.mms.req.query.RetailerStatisticsReq;
import com.allwees.bs.module.mms.service.RetailerStatisticsService;
import com.allwees.core.common.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class RetailerStatisticsServiceImpl  implements RetailerStatisticsService {

    @Autowired
    private RetailerDao retailerDao;

   public Integer findYesterdayNewNum(){
       Date dateTo = DateUtil.getPreDay(DateUtil.getDayLast(new Date()));
       Date dateFrom = DateUtil.addHour(dateTo,-24);
       RetailerStatisticsReq retailerStatisticsReq = new RetailerStatisticsReq();
       retailerStatisticsReq.setDateFrom(dateFrom);
       retailerStatisticsReq.setDateTo(dateTo);
       return retailerDao.findRetailerNum(retailerStatisticsReq);
   }

   public Integer findTotalRetailerNum(){
       RetailerStatisticsReq retailerStatisticsReq = new RetailerStatisticsReq();
       retailerStatisticsReq.setDateFrom(DateUtil.getDate(2020,0,1));
       retailerStatisticsReq.setDateTo(new Date());
       return retailerDao.findRetailerNum(retailerStatisticsReq);
   }


}
